Inside Macintosh: Macintosh Toolbox Essentials

Previous | Chapter Top | Chapter Contents | Next

The Window Resource

You typically define a window resource for each type of window that your application creates. Figure 3-2 illustrates a compiled 'WIND' resource.

Figure 2 Structure of a compiled window ( 'WIND' ) resource

A compiled version of a window resource contains the following elements:

If you're using one of the standard window types described in Inside Macintosh: Macintosh Toolbox Essentials , the definition ID is one of the enumerators described in "Window Definition IDs" .

The seventh element of the resource can contain one of the values specified by these enumerators:

    enum {
        noAutoCenter            = 0x0000,   /* use initial location */
        centerMainScreen        = 0x280A,   /* center on main screen */
        alertPositionMainScreen             /* place in alert */
                                = 0x300A,   /* position on main screen */
        staggerMainScreen       = 0x380A,   /* stagger on main screen */
        centerParentWindow      = 0xA80A,   /* center on parent window */
        alertPositionParentWindow           /* place in alert position
                                = 0xB00A,   /* on parent window */
        staggerParentWindow     = 0xB80A,   /* stagger relative
                                            /* to parent window */
        centerParentWindowScreen            /* center on parent
                                = 0x680A,   /* window screen */
        alertPositionParentWindowScreen
                                = 0x700A,   /* place in alert position
                                            /* on parent window screen */
        staggerParentWindowScreen           /* stagger on parent
                                = 0x780A    /* window screen */
    };

The positioning constants are convenient when the user is creating new documents or when you are handling your own dialog boxes and alert boxes. When you are creating a new window to display a previously saved document, however, you should display the new window in the same rectangle as the previous window (that is, the window the document occupied when it was last saved).

Use the GetNewCWindow (GetNewCWindow) or GetNewWindow (GetNewWindow) function to read a 'WIND' resource. Both functions create a new window record and fill it in according to the values specified in a 'WIND' resource.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next